package com.xhu.collegestudentrentalsystem.module.user.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xhu.collegestudentrentalsystem.module.user.entity.DiscussPost;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author zhu huilin
 * @date 2023/4/2 11:21
 */
public interface DiscussPostDAO extends BaseMapper<DiscussPost> {
    /**
     * 修改帖子表中的评论数量
     */
    @Update("update discuss_post set comment_count = comment_count + #{count} where id = #{discussPostId}")
    public Integer updateDiscussPostCommentCount(@Param("count")Integer count, @Param("discussPostId")Long discussPostId);

    /**
     * 修改帖子表中帖子的状态
     */
    @Update("update discuss_post set post_status = #{status} where id = #{id}")
    public Integer updateDiscussPostStatus(@Param("id")Long discussPostId, @Param("status")Integer status);

    /**
     * 修改帖子类型，0-普通；1-置顶
     */
    @Update("update discuss_post set post_type = #{type} where id = #{id}")
    public Integer updateDiscussPostType(@Param("id")Long discussPostId, @Param("type")Integer type);

}
